package com.sfc.sdsr.server;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import org.apache.log4j.Logger;

public class ClientData {

	private Logger log = Logger.getLogger(getClass());
	private byte operation;
	private Object operationParameter;

	public ClientData(byte[] data, byte operation) {
		this.operation = operation;
		try {
			ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(data));
			operationParameter = ois.readObject();
		} catch (IOException e) {
			log.error("failed to deserialize java object");
			this.operation = -1;
		} catch (ClassNotFoundException e) {
			log.error("Class not found when deserializing");
			this.operation = -1;
		}
	}

	public byte getOperation() {
		return operation;
	}

	public Object getOperationParameter() {
		return operationParameter;
	}
}
